Robotics 1.0
Lesson 12: Let's Drive - Control the Rover

Purpose: Learn how to connect a joystick and read its inputs using CircuitPython. Students will use the joystick to control the rover's movement, such as forward, backward, turning and speed control.

No. of. Classes

1 - 1 (Time: 1 hour and 30 minutes, each group has a maximum of 4 students).

Materials Required
  • CPX (Arduino board)

  • Acrylic chassis kit

  • Crickit

  • Joystick

  • Jumper wires

  • Battery pack 5v

Prior knowledge

Students should already know how DC motors are connected to crickit and controlled through code, including basic forward and stop movement of the rover using buttons.

Exercises

Exercise:1



Connecting a joystick


  • Click here to view the instructions

  • Click here to view the instructions and code for reading the values of the Joystick sensor. Click here to listen to the solution audio (Important).


  • Exercise:2



    Steer the Bot - Move the rover using the joystick in four directions.


  • Click here to view the instructions and code for reading the values of the Joystick sensor.
  • Solution



  • Click here to view the solution document for Exercise 2.
  • Click here to watch the solution video for Exercise 2.
  • Teacher's Instruction
    1. Introduce the joystick and explain that it gives analog signals (X and Y values) and a digital signal (Z value).
    2. Relate the joystick to real-life devices such as game controllers or remote-controlled cars.
    3. Show how to connect the joystick to the Crickit and CPX (VCC, GND, X-axis, Y-axis).
    4. Demonstrate a simple CircuitPython program to read joystick values and print them.
    5. Ask students to observe how the values change when the joystick is moved.
    6. Ask students to observe how the values range from minimum to maximum depending on the movement.
    7. Guide students to map joystick directions to rover movement (forward, backward, left, right, stop).
    8. Conclude by reminding students that the joystick is an input device and motors are output devices.
    9. Encourage students to be curious about how joystick works. Here is a nice video showing how Joystick works
    10. In a joystick, why are x and y values analog but z value is digital? Discuss